#ifndef _PARAMS_
#define _PARAMS_

#include <pthread.h>
#include <iostream>
#include <string.h>
#include <time.h> 

using namespace std;

typedef unsigned __int64 	BITBOARD;
typedef unsigned int		uint;

#define conv_bitboard(a7,a6,a5,a4,a3,a2,a1,a0)		\
	  (	((BITBOARD)(a7) << 56 ) | 		\
		((BITBOARD)(a6) << 48 ) | 		\
		((BITBOARD)(a5) << 40 ) | 		\
		((BITBOARD)(a4) << 32 ) | 		\
		((BITBOARD)(a3) << 24 ) | 		\
		((BITBOARD)(a2) << 16 ) | 		\
		((BITBOARD)(a1) <<  8 ) | 		\
		((BITBOARD)(a0)       ) )  		
		
#define shift_left(b) 	( b << 1 )
#define shift_right(b) 	( b >> 1 )
#define shift_up(b)     ( b << 8 )
#define shift_down(b)   ( b >> 8 )

#define cord_to_square(col,row)		( (row+2)*10 + (col) )

		
#define TIMER_START(a)	{ a = clock();  }
#define TIMER_GET(a)	( clock() - (a) )

#define POPCNT64(k,n) 																		\
{ 																							\
	BITBOARD __itimed = k;																	\
	__itimed = __itimed - ((__itimed >> 1) & 0x5555555555555555);							\
	__itimed = (__itimed & 0x3333333333333333) + ((__itimed >> 2) & 0x3333333333333333);	\
	n = (((__itimed + (__itimed >> 4)) & 0x0F0F0F0F0F0F0F0F) *								\
          0x0101010101010101) >> 56;														\
}

#define CAPTURE_VALUE(my,opp)	( ((opp)<<16) - my )

const int MSG_GO         		= 1;
const int MSG_STOP_ENGINE		= 200;

typedef	unsigned __int64 T_MOVE;

#define CONV_T_MOVE(from,to,killed,promo,enpassant,flags)  ( (from) | ((to)<<8) | ((killed)<<16) | ((promo)<<24) | ((enpassant)<<32) | ((flags)<<40) )

	
const BITBOARD b00000000		=   0;
const BITBOARD b00000001		=   1;	
const BITBOARD b00000010		=   2;
const BITBOARD b00000011		=   3;	
const BITBOARD b00000100		=   4;
const BITBOARD b00000101		=   5;	
const BITBOARD b00000110		=   6;
const BITBOARD b00000111		=   7;	
const BITBOARD b00001000		=   8;
const BITBOARD b00001001		=   9;	
const BITBOARD b00001010		=  10;
const BITBOARD b00001011		=  11;
const BITBOARD b00001100		=  12;
const BITBOARD b00001101		=  13;	
const BITBOARD b00001110		=  14;
const BITBOARD b00001111		=  15;
const BITBOARD b00010000		=  16;
const BITBOARD b00010001		=  17;	
const BITBOARD b00010010		=  18;
const BITBOARD b00010011		=  19;	
const BITBOARD b00010100		=  20;
const BITBOARD b00010101		=  21;	
const BITBOARD b00010110		=  22;
const BITBOARD b00010111		=  23;	
const BITBOARD b00011000		=  24;
const BITBOARD b00011001		=  25;	
const BITBOARD b00011010		=  26;
const BITBOARD b00011011		=  27;	
const BITBOARD b00011100		=  28;
const BITBOARD b00011101		=  29;	
const BITBOARD b00011110		=  30;
const BITBOARD b00011111		=  31;
const BITBOARD b00100000		=  32;
const BITBOARD b00100001		=  33;	
const BITBOARD b00100010		=  34;
const BITBOARD b00100011		=  35;	
const BITBOARD b00100100		=  36;
const BITBOARD b00100101		=  37;	
const BITBOARD b00100110		=  38;
const BITBOARD b00100111		=  39;	
const BITBOARD b00101000		=  40;
const BITBOARD b00101001		=  41;	
const BITBOARD b00101010		=  42;
const BITBOARD b00101011		=  43;	
const BITBOARD b00101100		=  44;
const BITBOARD b00101101		=  45;	
const BITBOARD b00101110		=  46;
const BITBOARD b00101111		=  47;
const BITBOARD b00110000		=  48;
const BITBOARD b00110001		=  49;	
const BITBOARD b00110010		=  50;
const BITBOARD b00110011		=  51;	
const BITBOARD b00110100		=  52;
const BITBOARD b00110101		=  53;	
const BITBOARD b00110110		=  54;
const BITBOARD b00110111		=  55;	
const BITBOARD b00111000		=  56;
const BITBOARD b00111001		=  57;	
const BITBOARD b00111010		=  58;
const BITBOARD b00111011		=  59;	
const BITBOARD b00111100		=  60;
const BITBOARD b00111101		=  61;	
const BITBOARD b00111110		=  62;
const BITBOARD b00111111		=  63;
const BITBOARD b01000000		=  64;
const BITBOARD b01000001		=  65;	
const BITBOARD b01000010		=  66;
const BITBOARD b01000011		=  67;	
const BITBOARD b01000100		=  68;
const BITBOARD b01000101		=  69;	
const BITBOARD b01000110		=  70;
const BITBOARD b01000111		=  71;	
const BITBOARD b01001000		=  72;
const BITBOARD b01001001		=  73;	
const BITBOARD b01001010		=  74;
const BITBOARD b01001011		=  75;	
const BITBOARD b01001100		=  76;
const BITBOARD b01001101		=  77;	
const BITBOARD b01001110		=  78;
const BITBOARD b01001111		=  79;
const BITBOARD b01010000		=  80;
const BITBOARD b01010001		=  81;	
const BITBOARD b01010010		=  82;
const BITBOARD b01010011		=  83;	
const BITBOARD b01010100		=  84;
const BITBOARD b01010101		=  85;	
const BITBOARD b01010110		=  86;
const BITBOARD b01010111		=  87;	
const BITBOARD b01011000		=  88;
const BITBOARD b01011001		=  89;	
const BITBOARD b01011010		=  90;
const BITBOARD b01011011		=  91;	
const BITBOARD b01011100		=  92;
const BITBOARD b01011101		=  93;	
const BITBOARD b01011110		=  94;
const BITBOARD b01011111		=  95;
const BITBOARD b01100000		=  96;
const BITBOARD b01100001		=  97;	
const BITBOARD b01100010		=  98;
const BITBOARD b01100011		=  99;	
const BITBOARD b01100100		= 100;
const BITBOARD b01100101		= 101;	
const BITBOARD b01100110		= 102;
const BITBOARD b01100111		= 103;	
const BITBOARD b01101000		= 104;
const BITBOARD b01101001		= 105;	
const BITBOARD b01101010		= 106;
const BITBOARD b01101011		= 107;	
const BITBOARD b01101100		= 108;
const BITBOARD b01101101		= 109;	
const BITBOARD b01101110		= 110;
const BITBOARD b01101111		= 111;
const BITBOARD b01110000		= 112;
const BITBOARD b01110001		= 113;	
const BITBOARD b01110010		= 114;
const BITBOARD b01110011		= 115;	
const BITBOARD b01110100		= 116;
const BITBOARD b01110101		= 117;	
const BITBOARD b01110110		= 118;
const BITBOARD b01110111		= 119;	
const BITBOARD b01111000		= 120;
const BITBOARD b01111001		= 121;	
const BITBOARD b01111010		= 122;
const BITBOARD b01111011		= 123;	
const BITBOARD b01111100		= 124;
const BITBOARD b01111101		= 125;	
const BITBOARD b01111110		= 126;
const BITBOARD b01111111		= 127;
const BITBOARD b10000000		= 128;
const BITBOARD b10000001		= 129;	
const BITBOARD b10000010		= 130;
const BITBOARD b10000011		= 131;	
const BITBOARD b10000100		= 132;
const BITBOARD b10000101		= 133;	
const BITBOARD b10000110		= 134;
const BITBOARD b10000111		= 135;	
const BITBOARD b10001000		= 136;
const BITBOARD b10001001		= 137;	
const BITBOARD b10001010		= 138;
const BITBOARD b10001011		= 139;	
const BITBOARD b10001100		= 140;
const BITBOARD b10001101		= 141;	
const BITBOARD b10001110		= 142;
const BITBOARD b10001111		= 143;
const BITBOARD b10010000		= 144;
const BITBOARD b10010001		= 145;	
const BITBOARD b10010010		= 146;
const BITBOARD b10010011		= 147;	
const BITBOARD b10010100		= 148;
const BITBOARD b10010101		= 149;	
const BITBOARD b10010110		= 150;
const BITBOARD b10010111		= 151;	
const BITBOARD b10011000		= 152;
const BITBOARD b10011001		= 153;	
const BITBOARD b10011010		= 154;
const BITBOARD b10011011		= 155;	
const BITBOARD b10011100		= 156;
const BITBOARD b10011101		= 157;	
const BITBOARD b10011110		= 158;
const BITBOARD b10011111		= 159;
const BITBOARD b10100000		= 160;
const BITBOARD b10100001		= 161;	
const BITBOARD b10100010		= 162;
const BITBOARD b10100011		= 163;	
const BITBOARD b10100100		= 164;
const BITBOARD b10100101		= 165;	
const BITBOARD b10100110		= 166;
const BITBOARD b10100111		= 167;	
const BITBOARD b10101000		= 168;
const BITBOARD b10101001		= 169;	
const BITBOARD b10101010		= 170;
const BITBOARD b10101011		= 171;	
const BITBOARD b10101100		= 172;
const BITBOARD b10101101		= 173;	
const BITBOARD b10101110		= 174;
const BITBOARD b10101111		= 175;
const BITBOARD b10110000		= 176;
const BITBOARD b10110001		= 177;	
const BITBOARD b10110010		= 178;
const BITBOARD b10110011		= 179;	
const BITBOARD b10110100		= 180;
const BITBOARD b10110101		= 181;	
const BITBOARD b10110110		= 182;
const BITBOARD b10110111		= 183;	
const BITBOARD b10111000		= 184;
const BITBOARD b10111001		= 185;	
const BITBOARD b10111010		= 186;
const BITBOARD b10111011		= 187;	
const BITBOARD b10111100		= 188;
const BITBOARD b10111101		= 189;	
const BITBOARD b10111110		= 190;
const BITBOARD b10111111		= 191;
const BITBOARD b11000000		= 192;
const BITBOARD b11000001		= 193;	
const BITBOARD b11000010		= 194;
const BITBOARD b11000011		= 195;	
const BITBOARD b11000100		= 196;
const BITBOARD b11000101		= 197;	
const BITBOARD b11000110		= 198;
const BITBOARD b11000111		= 199;	
const BITBOARD b11001000		= 200;
const BITBOARD b11001001		= 201;	
const BITBOARD b11001010		= 202;
const BITBOARD b11001011		= 203;	
const BITBOARD b11001100		= 204;
const BITBOARD b11001101		= 205;	
const BITBOARD b11001110		= 206;
const BITBOARD b11001111		= 207;
const BITBOARD b11010000		= 208;
const BITBOARD b11010001		= 209;	
const BITBOARD b11010010		= 210;
const BITBOARD b11010011		= 211;	
const BITBOARD b11010100		= 212;
const BITBOARD b11010101		= 213;	
const BITBOARD b11010110		= 214;
const BITBOARD b11010111		= 215;	
const BITBOARD b11011000		= 216;
const BITBOARD b11011001		= 217;	
const BITBOARD b11011010		= 218;
const BITBOARD b11011011		= 219;	
const BITBOARD b11011100		= 220;
const BITBOARD b11011101		= 221;	
const BITBOARD b11011110		= 222;
const BITBOARD b11011111		= 223;
const BITBOARD b11100000		= 224;
const BITBOARD b11100001		= 225;	
const BITBOARD b11100010		= 226;
const BITBOARD b11100011		= 227;	
const BITBOARD b11100100		= 228;
const BITBOARD b11100101		= 229;	
const BITBOARD b11100110		= 230;
const BITBOARD b11100111		= 231;	
const BITBOARD b11101000		= 232;
const BITBOARD b11101001		= 233;	
const BITBOARD b11101010		= 234;
const BITBOARD b11101011		= 235;	
const BITBOARD b11101100		= 236;
const BITBOARD b11101101		= 237;	
const BITBOARD b11101110		= 238;
const BITBOARD b11101111		= 239;
const BITBOARD b11110000		= 240;
const BITBOARD b11110001		= 241;	
const BITBOARD b11110010		= 242;
const BITBOARD b11110011		= 243;	
const BITBOARD b11110100		= 244;
const BITBOARD b11110101		= 245;	
const BITBOARD b11110110		= 246;
const BITBOARD b11110111		= 247;	
const BITBOARD b11111000		= 248;
const BITBOARD b11111001		= 249;	
const BITBOARD b11111010		= 250;
const BITBOARD b11111011		= 251;	
const BITBOARD b11111100		= 252;
const BITBOARD b11111101		= 253;	
const BITBOARD b11111110		= 254;
const BITBOARD b11111111		= 255;

enum SQUARE_NOTATION 
{
	A1 = 20, B1, C1, D1, E1, F1, G1, H1,
	A2 = 30, B2, C2, D2, E2, F2, G2, H2,
	A3 = 40, B3, C3, D3, E3, F3, G3, H3,
	A4 = 50, B4, C4, D4, E4, F4, G4, H4,
	A5 = 60, B5, C5, D5, E5, F5, G5, H5,
	A6 = 70, B6, C6, D6, E6, F6, G6, H6,
	A7 = 80, B7, C7, D7, E7, F7, G7, H7,
	A8 = 90, B8, C8, D8, E8, F8, G8, H8
};

#endif
